﻿using System;

namespace Effects.Effects.Tools
{
    /// <summary>
    ///  Sine  wave oscillator.
    /// </summary>
    /// <remarks>
    ///  Class implements sine wave oscillator. 
    /// </remarks>
    public class SinOscilator : Oscillator
    {
        /// <summary>
        ///   Gets ocillator's value at given time.  Overridden to behave as sine wave oscillator. 
        /// </summary>
        /// <param name="time"> time of the oscilation </param>
        /// <returns> Value at given time. </returns>
        public override double Amplitude(double time)
        {
            time = time % period;
            return Math.Sin((time / period) * 2 * Math.PI);
        }

        /// <summary>
        ///  Makes stepTime advance of oscillator's time and returns current value of oscillation.  Overridden to behave as sine wave oscillator.
        /// </summary>
        /// <param name="stepTime"> Length of a step that oscillator advances in time. </param>
        /// <returns> Current value of an oscillator after the step.</returns>
        public override double Step(double stepTime)
        {
            time += stepTime;
            time %= period;
            return Math.Sin((time / period) * 2 * Math.PI);
        }
    }
}